<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>无标题文档</title>
</head>

<body>
	<?php
	/* 打开页面控制 */
	include("pagecontrol.php");	  
	  //1、获取表单递交的信息
	$userName=$_REQUEST["userName"];
	$userPwd=$_REQUEST["userPwd"];	
	$code=$_REQUEST['passcode'];
	session_start();
	  //2、表单信息验证
	if(empty($userName)){
		pagecontrol("用户名不能为空！",1,"");
		die();
	}	
	if( $code !=  $_SESSION["validcode"])
	{
		pagecontrol("验证码不正确！",1,'');
	} 
	/* 打开数据库 */
	$conn=mysql_connect("localhost","root","") or die("数据库连接不成功");
	$db=mysql_select_db("test") or die("数据库指定不成功");
	  //4、数据库访问（查询、插入、更新、删除）
	$sql="select * from user where uname='".$userName."'";
	$rs=mysql_query($sql);
	if($row=mysql_fetch_array($rs)){
	  
	  	if($row['upwd']==$userPwd){
	  		session_start();
	  		$_SESSION["userid"]=$row["uid"];
	  		$_SESSION["userName"]=$row["uname"];
	  		pagecontrol("",3,"../couplet-4.php");
	  	}
	  	else
	  	{
	  		pagecontrol("密码不正确！",1,"");	
	  	}
	  }
	  else
	  {
	  	pagecontrol("用户名不存在！",1,"");		
	  }
	  /* 关闭数据库 */	
	  mysql_close($conn);
	  ?>
	</body>
	</html>